package zkj.servlet;

import java.io.IOException;
import java.util.Enumeration;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ServletDemo5 extends HttpServlet {

	/**
	 * ServletConfig 获取初始化参数
	 */
	private static final long serialVersionUID = 1L;

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		ServletConfig sc = getServletConfig();
		 String name = (String) sc.getInitParameter("name");
		// response.getWriter().write(name);
		Enumeration names = sc.getInitParameterNames();
		// response.getWriter().write("<br/>-------------------------------<br/>");
		while (names.hasMoreElements()) {
			String n = (String) names.nextElement();
			response.getWriter().write(sc.getInitParameter(n) + "<br/>");
		}
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request, response);
	}

}
